package com.repast.controller;

import java.io.UnsupportedEncodingException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.repast.common.ServerResponse;
import com.repast.pojo.Opinion;
import com.repast.service.IOpinionService;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

@Controller
@RequestMapping("/opinion/")
public class OpinionController {
	
	@Autowired
	private IOpinionService opinionService;
	
	//提交意见反馈,0表示提交成功,1016,提交意见反馈失败
	@RequestMapping("submit.do")
	@ResponseBody
	public ServerResponse submitOpinion(String json) throws Exception{
		Opinion opinion = new Opinion();
		JSONObject jsonStr = JSONObject.fromObject(json);
		String opinionContent = jsonStr.getString("opinionContent");
		opinion.setOpinionContent(opinionContent);
		opinion.setOpinionContactWay(jsonStr.getString("opinionContactWay"));
		opinion.setOpenid(jsonStr.getString("openid"));
		return opinionService.submitOpinion(opinion);
	}
}
